package com.koocloud.electroplatemanage.utils;

import org.springframework.util.StringUtils;

/**
 * @program: electroplatemanage
 * @description: 二次校验，用于curd
 * @author: zww
 * @create: 2020-10-20 18:58
 */
public class SecondCheck {
    public static boolean jobNumCheck(String jobNum) {
        String regex = "^[A-Z][0-9]{6}";
        return jobNum.matches(regex);
    }
    public static boolean codeCheck(String code) {
        String regex = "^[A-Z][0-9]{3}";
        return code.matches(regex);
    }
    public static boolean formulaCheck(String formula) {
        if(StringUtils.isEmpty(formula)) {
            return true;
        }
        else if("FFFFF".equals(formula.substring(0,5))) {
            return true;
        }
        else {
                if (formula.length() == 9) {
                    if (Integer.parseInt(formula.substring(1, 4)) <= 255 && Integer.parseInt(formula.substring(6, 9)) <= 255) {
                        String regex = "^[F][0-9]{3}[=\\+\\-\\*/]{1}[F][0-9]{3}";
                        return formula.matches(regex);
                    } else {
                        return false;
                    }
                } else {
                    return false;
                }

        }
    }
}